/**
 * 
 */
package model.world.tile;

/**
 * @author Justin
 *
 */
public enum TileDirection {
	NORTH(0),
	NORTH_EAST(1),
	SOUTH_EAST(2),
	SOUTH(3),
	SOUTH_WEST(4),
	NORTH_WEST(5);
	
	private final int id;
	
	TileDirection(int id){
		this.id = id;
	}
	public int toInt(){
		return id;
	}
	
	public static TileDirection getDirection(long dx, long dy){
		if(dy < 0){
			if(dx < 0)
				return TileDirection.NORTH_WEST;
			else if(dx == 0)
				return TileDirection.NORTH;
			else
				return TileDirection.NORTH_EAST;
		}else if(dy > 0){
			if(dx < 0)
				return TileDirection.SOUTH_WEST;
			else if(dx == 0)
				return TileDirection.SOUTH;
			else
				return TileDirection.SOUTH_EAST;
		}else{
			if(dx < 0)
				return TileDirection.NORTH_WEST;
			else if(dx == 0)
				return null;
			else
				return TileDirection.SOUTH_EAST;
		}
	}
}
